/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package PaqCliente;

import PaqCORBA.exDemasiadasPreguntas;
import PaqCORBA.exPreguntaNoExiste;
import java.awt.*;
import java.util.Calendar;
//import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;

public class p_principal extends javax.swing.JPanel 
{
    private Cliente cli;
    private short maxResp = 4;
    private DefaultListModel Temas = new DefaultListModel();
    private Calendar hoy = Calendar.getInstance(Locale.ROOT);
    private Integer numPreguntas = 0;
    
    

    /**
     * Creates new form p_principal
     */
    public p_principal() {
        initComponents();
        cli = new Cliente();
        fechaIni_in.setCalendar(hoy);
        fechaFin_in.setCalendar(hoy);
        GUI_Profesor.setVisible(false);
        GUI_Alumno.setVisible(false);
        //this.add(autenticacion, BorderLayout.CENTER);
        this.setSize(790,580);
    }
    
    @Override
    public void paintComponent(Graphics g)
    {
        Dimension tam = getSize();
        ImageIcon imagenFondo = new ImageIcon(getClass().getResource("/los/imagen/Fondo.gif"));
        g.drawImage(imagenFondo.getImage(), 0, 0, tam.width, tam.height, null);
        setOpaque(false);
        super.paintComponent(g);
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        respuesta1 = new javax.swing.ButtonGroup();
        respuesta2 = new javax.swing.ButtonGroup();
        respuesta3 = new javax.swing.ButtonGroup();
        respuesta4 = new javax.swing.ButtonGroup();
        autenticacion = new javax.swing.JLayeredPane();
        titulo = new javax.swing.JLabel();
        et_usuario = new javax.swing.JLabel();
        et_pass = new javax.swing.JLabel();
        user_in = new javax.swing.JTextField();
        in_pass = new javax.swing.JPasswordField();
        b_entrar = new javax.swing.JButton();
        GUI_Profesor = new javax.swing.JLayeredPane();
        et_titProfesor = new javax.swing.JLabel();
        menu_profesor = new javax.swing.JTabbedPane();
        gestionar_preguntas = new javax.swing.JPanel();
        p_gestionar = new javax.swing.JTabbedPane();
        crear_preguntras = new javax.swing.JPanel();
        et_enunciado = new javax.swing.JLabel();
        scroll_enunciado = new javax.swing.JScrollPane();
        enunciado_in = new javax.swing.JTextArea();
        et_ID = new javax.swing.JLabel();
        et_respuestas = new javax.swing.JLabel();
        respuesta1_in = new javax.swing.JTextField();
        et_1 = new javax.swing.JLabel();
        et_2 = new javax.swing.JLabel();
        et_3 = new javax.swing.JLabel();
        et_4 = new javax.swing.JLabel();
        respuesta2_in = new javax.swing.JTextField();
        respuesta3_in = new javax.swing.JTextField();
        respuesta4_in = new javax.swing.JTextField();
        b_crear = new javax.swing.JButton();
        et_titCrearExamen = new javax.swing.JLabel();
        et_tema = new javax.swing.JLabel();
        asignatura_in = new javax.swing.JComboBox();
        tema_in = new javax.swing.JComboBox();
        check1_in = new javax.swing.JCheckBox();
        check2_in = new javax.swing.JCheckBox();
        check3_in = new javax.swing.JCheckBox();
        check4_in = new javax.swing.JCheckBox();
        et_correcta = new javax.swing.JLabel();
        ed_preg_correcta = new javax.swing.JPanel();
        et_titEdicionPreguntas1 = new javax.swing.JLabel();
        et_edAsignatura1 = new javax.swing.JLabel();
        et_edTema1 = new javax.swing.JLabel();
        ed_tema_in = new javax.swing.JComboBox();
        et_edPregunta1 = new javax.swing.JLabel();
        ed_pregunta_in = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane8 = new javax.swing.JScrollPane();
        ed_enunciado_in = new javax.swing.JTextArea();
        et_edResp5 = new javax.swing.JLabel();
        ed_respuesta1_in = new javax.swing.JTextField();
        et_edResp6 = new javax.swing.JLabel();
        ed_respuesta2_in = new javax.swing.JTextField();
        et_edResp7 = new javax.swing.JLabel();
        ed_respuesta3_in = new javax.swing.JTextField();
        et_edResp8 = new javax.swing.JLabel();
        ed_respuesta4_in = new javax.swing.JTextField();
        b_editar1 = new javax.swing.JButton();
        ed_check1_in = new javax.swing.JCheckBox();
        ed_check2_in = new javax.swing.JCheckBox();
        ed_check3_in = new javax.swing.JCheckBox();
        ed_check4_in = new javax.swing.JCheckBox();
        ed_asignatura_in = new javax.swing.JComboBox();
        borrar_preguntas = new javax.swing.JPanel();
        b_asignatura = new javax.swing.JComboBox();
        b_tema = new javax.swing.JComboBox();
        b_pregunta = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        borrar = new javax.swing.JButton();
        lanzar_examen = new javax.swing.JPanel();
        fechaIni_in = new com.toedter.calendar.JDateChooser();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        fechaFin_in = new com.toedter.calendar.JDateChooser();
        lanzar_titulo = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        creaEx_asig_in = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        creaEx_tema_in = new javax.swing.JComboBox();
        b_anyadir_tema = new javax.swing.JButton();
        b_crearEx = new javax.swing.JButton();
        jScrollPane9 = new javax.swing.JScrollPane();
        temas_anyadidos = new javax.swing.JList();
        jLabel1 = new javax.swing.JLabel();
        creaEx_numPreguntas_in = new javax.swing.JTextField();
        GUI_Alumno = new javax.swing.JLayeredPane();
        jLabel2 = new javax.swing.JLabel();
        menu_alumno = new javax.swing.JTabbedPane();
        Examenes = new javax.swing.JPanel();
        listaExamenes = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        empezar_examen = new javax.swing.JButton();
        Asignaturas = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        ListaAsignaturas = new javax.swing.JTable();
        examen = new javax.swing.JPanel();
        Exam = new javax.swing.JLabel();
        Asignatura = new javax.swing.JLabel();
        asig = new javax.swing.JTextField();
        Enunciado = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        enunciado = new javax.swing.JTextArea();
        jLabel4 = new javax.swing.JLabel();
        R_1 = new javax.swing.JCheckBox();
        R_2 = new javax.swing.JCheckBox();
        jScrollPane4 = new javax.swing.JScrollPane();
        resp_2 = new javax.swing.JTextArea();
        R_3 = new javax.swing.JCheckBox();
        jScrollPane5 = new javax.swing.JScrollPane();
        resp_3 = new javax.swing.JTextArea();
        R_4 = new javax.swing.JCheckBox();
        jScrollPane6 = new javax.swing.JScrollPane();
        resp_4 = new javax.swing.JTextArea();
        SiguientePregunta = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        resp_1 = new javax.swing.JTextArea();

        setMaximumSize(new java.awt.Dimension(850, 610));
        setMinimumSize(new java.awt.Dimension(800, 600));
        setPreferredSize(new java.awt.Dimension(850, 610));

        autenticacion.setBackground(new java.awt.Color(229, 242, 238));
        autenticacion.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(231, 253, 243), new java.awt.Color(237, 253, 253), new java.awt.Color(148, 159, 181), new java.awt.Color(221, 229, 229)));
        autenticacion.setOpaque(true);

        titulo.setFont(new java.awt.Font("Arial Black", 0, 18)); // NOI18N
        titulo.setText("AUTENTICACI?N");
        titulo.setBounds(180, 10, 170, 20);
        autenticacion.add(titulo, javax.swing.JLayeredPane.DEFAULT_LAYER);

        et_usuario.setFont(new java.awt.Font("Century Schoolbook L", 1, 18)); // NOI18N
        et_usuario.setText("Usuario: ");
        et_usuario.setBounds(40, 60, 110, 24);
        autenticacion.add(et_usuario, javax.swing.JLayeredPane.DEFAULT_LAYER);

        et_pass.setFont(new java.awt.Font("Century Schoolbook L", 1, 18)); // NOI18N
        et_pass.setText("Contrase?a: ");
        et_pass.setBounds(40, 100, 130, 24);
        autenticacion.add(et_pass, javax.swing.JLayeredPane.DEFAULT_LAYER);

        user_in.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                user_inActionPerformed(evt);
            }
        });
        user_in.setBounds(180, 50, 170, 30);
        autenticacion.add(user_in, javax.swing.JLayeredPane.DEFAULT_LAYER);

        in_pass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                in_passActionPerformed(evt);
            }
        });
        in_pass.setBounds(180, 90, 170, 30);
        autenticacion.add(in_pass, javax.swing.JLayeredPane.DEFAULT_LAYER);

        b_entrar.setFont(new java.awt.Font("Georgia", 3, 15)); // NOI18N
        b_entrar.setText("ENTRAR");
        b_entrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b_entrarActionPerformed(evt);
            }
        });
        b_entrar.setBounds(200, 140, 120, 27);
        autenticacion.add(b_entrar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        GUI_Profesor.setBackground(new java.awt.Color(241, 255, 255));
        GUI_Profesor.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, null, null, new java.awt.Color(35, 53, 88), new java.awt.Color(126, 132, 160)));
        GUI_Profesor.setToolTipText("");
        GUI_Profesor.setMaximumSize(new java.awt.Dimension(700, 450));
        GUI_Profesor.setMinimumSize(new java.awt.Dimension(700, 450));
        GUI_Profesor.setName("");
        GUI_Profesor.setOpaque(true);

        et_titProfesor.setFont(new java.awt.Font("Impact", 3, 24)); // NOI18N
        et_titProfesor.setText("Men? Profesor");
        et_titProfesor.setBounds(340, 10, 160, 31);
        GUI_Profesor.add(et_titProfesor, javax.swing.JLayeredPane.DEFAULT_LAYER);

        menu_profesor.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(250, 234, 254), new java.awt.Color(160, 132, 189)));
        menu_profesor.setMinimumSize(new java.awt.Dimension(650, 430));
        menu_profesor.setPreferredSize(new java.awt.Dimension(650, 430));

        et_enunciado.setBackground(new java.awt.Color(254, 254, 254));
        et_enunciado.setText("Enunciado de la pregunta: ");
        et_enunciado.setOpaque(true);

        enunciado_in.setColumns(20);
        enunciado_in.setRows(5);
        enunciado_in.setText("Escribe tu enunciado aqu?!");
        scroll_enunciado.setViewportView(enunciado_in);

        et_ID.setBackground(new java.awt.Color(254, 254, 254));
        et_ID.setText("Asignatura:");
        et_ID.setOpaque(true);

        et_respuestas.setBackground(new java.awt.Color(254, 254, 254));
        et_respuestas.setText("Respuestas: ");
        et_respuestas.setOpaque(true);

        et_1.setText("1.");

        et_2.setText("2.");

        et_3.setText("3.");

        et_4.setText("4.");

        b_crear.setBackground(new java.awt.Color(223, 213, 232));
        b_crear.setFont(new java.awt.Font("Georgia", 3, 15)); // NOI18N
        b_crear.setText("CREAR");
        b_crear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b_crearActionPerformed(evt);
            }
        });

        et_titCrearExamen.setFont(new java.awt.Font("Georgia", 3, 18)); // NOI18N
        et_titCrearExamen.setText("CREAR PREGUNTAS NUEVAS");

        et_tema.setText("Tema: ");

        asignatura_in.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                asignatura_inItemStateChanged(evt);
            }
        });
        asignatura_in.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                asignatura_inActionPerformed(evt);
            }
        });

        check1_in.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                check1_inActionPerformed(evt);
            }
        });

        et_correcta.setText("Correctas: ");

        javax.swing.GroupLayout crear_preguntrasLayout = new javax.swing.GroupLayout(crear_preguntras);
        crear_preguntras.setLayout(crear_preguntrasLayout);
        crear_preguntrasLayout.setHorizontalGroup(
            crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(crear_preguntrasLayout.createSequentialGroup()
                .addGroup(crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(crear_preguntrasLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(et_ID)
                        .addGap(33, 33, 33)
                        .addComponent(asignatura_in, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(105, 105, 105)
                        .addComponent(et_tema, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tema_in, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(crear_preguntrasLayout.createSequentialGroup()
                        .addGap(209, 209, 209)
                        .addComponent(et_titCrearExamen))
                    .addGroup(crear_preguntrasLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(crear_preguntrasLayout.createSequentialGroup()
                                .addComponent(et_respuestas)
                                .addGap(230, 230, 230)
                                .addComponent(et_correcta))
                            .addGroup(crear_preguntrasLayout.createSequentialGroup()
                                .addGroup(crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, crear_preguntrasLayout.createSequentialGroup()
                                        .addComponent(et_4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(respuesta4_in))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, crear_preguntrasLayout.createSequentialGroup()
                                        .addComponent(et_3)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(respuesta3_in))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, crear_preguntrasLayout.createSequentialGroup()
                                        .addComponent(et_2)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(respuesta2_in))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, crear_preguntrasLayout.createSequentialGroup()
                                        .addComponent(et_1)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(respuesta1_in, javax.swing.GroupLayout.PREFERRED_SIZE, 288, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(34, 34, 34)
                                .addGroup(crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(check1_in)
                                    .addComponent(check2_in)
                                    .addComponent(check3_in)
                                    .addComponent(check4_in)))))
                    .addGroup(crear_preguntrasLayout.createSequentialGroup()
                        .addComponent(et_enunciado)
                        .addGap(31, 31, 31)
                        .addComponent(scroll_enunciado, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(crear_preguntrasLayout.createSequentialGroup()
                        .addGap(251, 251, 251)
                        .addComponent(b_crear, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(113, Short.MAX_VALUE))
        );
        crear_preguntrasLayout.setVerticalGroup(
            crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(crear_preguntrasLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(et_titCrearExamen)
                .addGroup(crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(et_ID)
                        .addComponent(asignatura_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(crear_preguntrasLayout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addGroup(crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(et_tema, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(tema_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18, 18, 18)
                .addGroup(crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(scroll_enunciado, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(crear_preguntrasLayout.createSequentialGroup()
                        .addComponent(et_enunciado)
                        .addGap(29, 29, 29)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                .addGroup(crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(et_respuestas)
                    .addComponent(et_correcta))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(et_1)
                    .addComponent(respuesta1_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(check1_in))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(respuesta2_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(et_2)
                    .addComponent(check2_in))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(respuesta3_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(et_3)
                    .addComponent(check3_in))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(crear_preguntrasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(respuesta4_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(et_4)
                    .addComponent(check4_in))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(b_crear)
                .addGap(24, 24, 24))
        );

        p_gestionar.addTab("Crear Preguntas", crear_preguntras);

        et_titEdicionPreguntas1.setFont(new java.awt.Font("Georgia", 3, 18)); // NOI18N
        et_titEdicionPreguntas1.setText("EDICI?N DE PREGUNTAS");

        et_edAsignatura1.setText("Asignatura: ");

        et_edTema1.setText("Tema: ");

        ed_tema_in.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                ed_tema_inItemStateChanged(evt);
            }
        });
        ed_tema_in.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ed_tema_inActionPerformed(evt);
            }
        });

        et_edPregunta1.setText("Pregunta: ");

        ed_pregunta_in.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ed_pregunta_inActionPerformed(evt);
            }
        });

        jLabel7.setText("Enunciado: ");

        ed_enunciado_in.setColumns(20);
        ed_enunciado_in.setRows(5);
        jScrollPane8.setViewportView(ed_enunciado_in);

        et_edResp5.setText("1.");

        et_edResp6.setText("2.");

        et_edResp7.setText("3.");

        et_edResp8.setText("4.");

        b_editar1.setFont(new java.awt.Font("Georgia", 3, 15)); // NOI18N
        b_editar1.setText("EDITAR");
        b_editar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b_editar1ActionPerformed(evt);
            }
        });

        ed_check1_in.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ed_check1_inActionPerformed(evt);
            }
        });

        ed_asignatura_in.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ed_asignatura_inActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout ed_preg_correctaLayout = new javax.swing.GroupLayout(ed_preg_correcta);
        ed_preg_correcta.setLayout(ed_preg_correctaLayout);
        ed_preg_correctaLayout.setHorizontalGroup(
            ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ed_preg_correctaLayout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ed_preg_correctaLayout.createSequentialGroup()
                        .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(et_edAsignatura1)
                            .addComponent(et_edTema1)
                            .addComponent(et_edPregunta1)
                            .addComponent(jLabel7))
                        .addGap(18, 18, 18)
                        .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(ed_tema_in, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(ed_pregunta_in, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jScrollPane8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 514, Short.MAX_VALUE)
                            .addComponent(ed_asignatura_in, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap())
                    .addGroup(ed_preg_correctaLayout.createSequentialGroup()
                        .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(ed_preg_correctaLayout.createSequentialGroup()
                                .addComponent(et_edResp5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(ed_respuesta1_in))
                            .addGroup(ed_preg_correctaLayout.createSequentialGroup()
                                .addComponent(et_edResp6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(ed_respuesta2_in)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ed_check2_in)
                            .addComponent(ed_check1_in))
                        .addGap(18, 18, 18)
                        .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(et_edResp7, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(et_edResp8, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(ed_respuesta3_in, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE)
                            .addComponent(ed_respuesta4_in))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ed_check3_in)
                            .addComponent(ed_check4_in))
                        .addGap(27, 27, 27))))
            .addGroup(ed_preg_correctaLayout.createSequentialGroup()
                .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ed_preg_correctaLayout.createSequentialGroup()
                        .addGap(276, 276, 276)
                        .addComponent(b_editar1, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(ed_preg_correctaLayout.createSequentialGroup()
                        .addGap(243, 243, 243)
                        .addComponent(et_titEdicionPreguntas1)))
                .addContainerGap(255, Short.MAX_VALUE))
        );
        ed_preg_correctaLayout.setVerticalGroup(
            ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ed_preg_correctaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(et_titEdicionPreguntas1)
                .addGap(18, 18, 18)
                .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(et_edAsignatura1)
                    .addComponent(ed_asignatura_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(4, 4, 4)
                .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ed_tema_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(et_edTema1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ed_pregunta_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(et_edPregunta1))
                .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ed_preg_correctaLayout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addComponent(jLabel7)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(ed_preg_correctaLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(ed_preg_correctaLayout.createSequentialGroup()
                        .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(ed_respuesta1_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(et_edResp5))
                        .addGap(10, 10, 10)
                        .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(ed_respuesta2_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(et_edResp6)))
                    .addGroup(ed_preg_correctaLayout.createSequentialGroup()
                        .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(ed_preg_correctaLayout.createSequentialGroup()
                                .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(ed_check3_in)
                                    .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(ed_respuesta3_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(et_edResp7)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, ed_preg_correctaLayout.createSequentialGroup()
                                .addGap(2, 2, 2)
                                .addComponent(ed_check1_in)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ed_check4_in)
                            .addComponent(ed_check2_in)
                            .addGroup(ed_preg_correctaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(ed_respuesta4_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(et_edResp8)))))
                .addGap(18, 18, 18)
                .addComponent(b_editar1)
                .addContainerGap())
        );

        p_gestionar.addTab("Editar Preguntas", ed_preg_correcta);

        b_asignatura.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b_asignaturaActionPerformed(evt);
            }
        });

        b_tema.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b_temaActionPerformed(evt);
            }
        });

        b_pregunta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b_preguntaActionPerformed(evt);
            }
        });

        jLabel10.setText("Asignatura:");

        jLabel11.setText("Tema:");

        jLabel12.setFont(new java.awt.Font("Georgia", 3, 18)); // NOI18N
        jLabel12.setText("BORRAR PREGUNTA");

        jLabel13.setText("Preguntas:");

        borrar.setText("Borrar");
        borrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                borrarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout borrar_preguntasLayout = new javax.swing.GroupLayout(borrar_preguntas);
        borrar_preguntas.setLayout(borrar_preguntasLayout);
        borrar_preguntasLayout.setHorizontalGroup(
            borrar_preguntasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, borrar_preguntasLayout.createSequentialGroup()
                .addContainerGap(33, Short.MAX_VALUE)
                .addComponent(jLabel10)
                .addGap(31, 31, 31)
                .addComponent(b_asignatura, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(98, 98, 98)
                .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(b_tema, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(133, 133, 133))
            .addGroup(borrar_preguntasLayout.createSequentialGroup()
                .addGroup(borrar_preguntasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(borrar_preguntasLayout.createSequentialGroup()
                        .addGap(258, 258, 258)
                        .addComponent(jLabel12))
                    .addGroup(borrar_preguntasLayout.createSequentialGroup()
                        .addGap(307, 307, 307)
                        .addComponent(jLabel13))
                    .addGroup(borrar_preguntasLayout.createSequentialGroup()
                        .addGap(256, 256, 256)
                        .addComponent(b_pregunta, javax.swing.GroupLayout.PREFERRED_SIZE, 211, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(borrar_preguntasLayout.createSequentialGroup()
                        .addGap(290, 290, 290)
                        .addComponent(borrar, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(279, Short.MAX_VALUE))
        );
        borrar_preguntasLayout.setVerticalGroup(
            borrar_preguntasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(borrar_preguntasLayout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(jLabel12)
                .addGap(26, 26, 26)
                .addGroup(borrar_preguntasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(b_tema, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11)
                    .addComponent(b_asignatura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addGap(44, 44, 44)
                .addComponent(jLabel13)
                .addGap(18, 18, 18)
                .addComponent(b_pregunta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(37, 37, 37)
                .addComponent(borrar)
                .addContainerGap(123, Short.MAX_VALUE))
        );

        p_gestionar.addTab("Borrar Preguntas", borrar_preguntas);

        javax.swing.GroupLayout gestionar_preguntasLayout = new javax.swing.GroupLayout(gestionar_preguntas);
        gestionar_preguntas.setLayout(gestionar_preguntasLayout);
        gestionar_preguntasLayout.setHorizontalGroup(
            gestionar_preguntasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(p_gestionar)
        );
        gestionar_preguntasLayout.setVerticalGroup(
            gestionar_preguntasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(p_gestionar)
        );

        menu_profesor.addTab("Gestionar Preguntas", gestionar_preguntas);

        lanzar_examen.setPreferredSize(new java.awt.Dimension(752, 420));

        fechaIni_in.setPreferredSize(new java.awt.Dimension(110, 27));
        fechaIni_in.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                fechaIni_inPropertyChange(evt);
            }
        });

        jLabel5.setText("Fecha inicio");

        jLabel6.setText("Fecha l?mite");

        fechaFin_in.setPreferredSize(new java.awt.Dimension(110, 27));
        fechaFin_in.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                fechaFin_inPropertyChange(evt);
            }
        });

        lanzar_titulo.setFont(new java.awt.Font("Georgia", 3, 18)); // NOI18N
        lanzar_titulo.setText("CREAR EXAMEN");

        jLabel8.setText("Asignatura: ");

        creaEx_asig_in.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                creaEx_asig_inActionPerformed(evt);
            }
        });

        jLabel9.setText("Temas: ");

        b_anyadir_tema.setText("A?adir Tema");
        b_anyadir_tema.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b_anyadir_temaActionPerformed(evt);
            }
        });

        b_crearEx.setFont(new java.awt.Font("Georgia", 3, 15)); // NOI18N
        b_crearEx.setText("CREAR EXAMEN");
        b_crearEx.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b_crearExActionPerformed(evt);
            }
        });

        temas_anyadidos.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(252, 245, 245), null, new java.awt.Color(188, 157, 157)));
        jScrollPane9.setViewportView(temas_anyadidos);

        jLabel1.setText("N?mero de preguntas: ");

        creaEx_numPreguntas_in.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                creaEx_numPreguntas_inActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout lanzar_examenLayout = new javax.swing.GroupLayout(lanzar_examen);
        lanzar_examen.setLayout(lanzar_examenLayout);
        lanzar_examenLayout.setHorizontalGroup(
            lanzar_examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(lanzar_examenLayout.createSequentialGroup()
                .addGap(260, 260, 260)
                .addComponent(lanzar_titulo)
                .addContainerGap())
            .addGroup(lanzar_examenLayout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addGroup(lanzar_examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(lanzar_examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(lanzar_examenLayout.createSequentialGroup()
                            .addComponent(jLabel5)
                            .addGap(18, 18, 18)
                            .addComponent(fechaIni_in, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(lanzar_examenLayout.createSequentialGroup()
                            .addComponent(jLabel6)
                            .addGap(18, 18, 18)
                            .addComponent(fechaFin_in, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(lanzar_examenLayout.createSequentialGroup()
                            .addComponent(jLabel9)
                            .addGap(52, 52, 52)
                            .addComponent(b_crearEx, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(lanzar_examenLayout.createSequentialGroup()
                            .addComponent(jLabel8)
                            .addGap(18, 18, 18)
                            .addGroup(lanzar_examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(creaEx_asig_in, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(lanzar_examenLayout.createSequentialGroup()
                                    .addComponent(creaEx_tema_in, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(b_anyadir_tema)))))
                    .addGroup(lanzar_examenLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(creaEx_numPreguntas_in, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(28, 28, 28))
        );
        lanzar_examenLayout.setVerticalGroup(
            lanzar_examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(lanzar_examenLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lanzar_titulo)
                .addGap(27, 27, 27)
                .addGroup(lanzar_examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(lanzar_examenLayout.createSequentialGroup()
                        .addGroup(lanzar_examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel5)
                            .addComponent(fechaIni_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(lanzar_examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(fechaFin_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6))
                        .addGap(18, 18, 18)
                        .addGroup(lanzar_examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(creaEx_asig_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(lanzar_examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(creaEx_tema_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(b_anyadir_tema))
                        .addGap(18, 18, 18)
                        .addGroup(lanzar_examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(creaEx_numPreguntas_in, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(66, 66, 66)
                        .addComponent(b_crearEx, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane9))
                .addContainerGap(71, Short.MAX_VALUE))
        );

        menu_profesor.addTab("Lanzar Examen", lanzar_examen);

        menu_profesor.setBounds(20, 40, 760, 440);
        GUI_Profesor.add(menu_profesor, javax.swing.JLayeredPane.DEFAULT_LAYER);

        GUI_Alumno.setBackground(new java.awt.Color(241, 240, 240));
        GUI_Alumno.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        GUI_Alumno.setMaximumSize(new java.awt.Dimension(700, 450));
        GUI_Alumno.setMinimumSize(new java.awt.Dimension(700, 450));
        GUI_Alumno.setOpaque(true);

        jLabel2.setFont(new java.awt.Font("Impact", 3, 24)); // NOI18N
        jLabel2.setText("Men? Alumno");
        jLabel2.setMaximumSize(new java.awt.Dimension(157, 31));
        jLabel2.setMinimumSize(new java.awt.Dimension(157, 31));
        jLabel2.setBounds(250, 10, 160, 31);
        GUI_Alumno.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        menu_alumno.setToolTipText("");

        listaExamenes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel3.setFont(new java.awt.Font("Impact", 3, 24)); // NOI18N
        jLabel3.setText("Ex?menes pendientes");

        empezar_examen.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        empezar_examen.setText("Empezar Examen");
        empezar_examen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                empezar_examenActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout ExamenesLayout = new javax.swing.GroupLayout(Examenes);
        Examenes.setLayout(ExamenesLayout);
        ExamenesLayout.setHorizontalGroup(
            ExamenesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ExamenesLayout.createSequentialGroup()
                .addGroup(ExamenesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ExamenesLayout.createSequentialGroup()
                        .addGap(215, 215, 215)
                        .addComponent(listaExamenes, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(ExamenesLayout.createSequentialGroup()
                        .addGap(255, 255, 255)
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(ExamenesLayout.createSequentialGroup()
                        .addGap(296, 296, 296)
                        .addComponent(empezar_examen)))
                .addContainerGap(222, Short.MAX_VALUE))
        );
        ExamenesLayout.setVerticalGroup(
            ExamenesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ExamenesLayout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(44, 44, 44)
                .addComponent(listaExamenes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(66, 66, 66)
                .addComponent(empezar_examen)
                .addContainerGap(171, Short.MAX_VALUE))
        );

        menu_alumno.addTab("Examenes", Examenes);

        ListaAsignaturas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null},
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "Asignaturas"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane7.setViewportView(ListaAsignaturas);

        javax.swing.GroupLayout AsignaturasLayout = new javax.swing.GroupLayout(Asignaturas);
        Asignaturas.setLayout(AsignaturasLayout);
        AsignaturasLayout.setHorizontalGroup(
            AsignaturasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AsignaturasLayout.createSequentialGroup()
                .addGap(150, 150, 150)
                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(153, Short.MAX_VALUE))
        );
        AsignaturasLayout.setVerticalGroup(
            AsignaturasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AsignaturasLayout.createSequentialGroup()
                .addGap(63, 63, 63)
                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(215, Short.MAX_VALUE))
        );

        menu_alumno.addTab("Asignatura", Asignaturas);

        menu_alumno.setBounds(10, 60, 760, 430);
        GUI_Alumno.add(menu_alumno, javax.swing.JLayeredPane.DEFAULT_LAYER);

        examen.setMinimumSize(new java.awt.Dimension(700, 450));
        examen.setPreferredSize(new java.awt.Dimension(700, 450));

        Exam.setFont(new java.awt.Font("Impact", 3, 24)); // NOI18N
        Exam.setText("Examen");

        Asignatura.setFont(new java.awt.Font("Verdana", 3, 12)); // NOI18N
        Asignatura.setText("Asignatura:");

        asig.setText("jTextField1");
        asig.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                asigActionPerformed(evt);
            }
        });

        Enunciado.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        Enunciado.setText("Enunciado:");

        enunciado.setColumns(20);
        enunciado.setRows(5);
        enunciado.setEnabled(false);
        jScrollPane2.setViewportView(enunciado);

        jLabel4.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        jLabel4.setText("Respuestas:");

        R_1.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        R_1.setText("1-");
        R_1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                R_1ActionPerformed(evt);
            }
        });

        R_2.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        R_2.setText("2-");

        resp_2.setColumns(20);
        resp_2.setRows(5);
        jScrollPane4.setViewportView(resp_2);

        R_3.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        R_3.setText("3-");

        resp_3.setColumns(20);
        resp_3.setRows(5);
        jScrollPane5.setViewportView(resp_3);

        R_4.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        R_4.setText("4-");

        resp_4.setColumns(20);
        resp_4.setRows(5);
        jScrollPane6.setViewportView(resp_4);

        SiguientePregunta.setText("Siguiente");

        resp_1.setColumns(20);
        resp_1.setRows(5);
        jScrollPane3.setViewportView(resp_1);

        javax.swing.GroupLayout examenLayout = new javax.swing.GroupLayout(examen);
        examen.setLayout(examenLayout);
        examenLayout.setHorizontalGroup(
            examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(examenLayout.createSequentialGroup()
                .addGroup(examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(examenLayout.createSequentialGroup()
                        .addGap(325, 325, 325)
                        .addComponent(Exam, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(examenLayout.createSequentialGroup()
                        .addGap(78, 78, 78)
                        .addGroup(examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(examenLayout.createSequentialGroup()
                                .addComponent(R_4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane6))
                            .addGroup(examenLayout.createSequentialGroup()
                                .addGroup(examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(Enunciado)
                                    .addComponent(Asignatura))
                                .addGap(30, 30, 30)
                                .addComponent(asig, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel4)
                            .addGroup(examenLayout.createSequentialGroup()
                                .addComponent(R_3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane5))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, examenLayout.createSequentialGroup()
                                .addComponent(R_2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 574, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(examenLayout.createSequentialGroup()
                                .addComponent(R_1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane3))
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 615, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(examenLayout.createSequentialGroup()
                        .addGap(288, 288, 288)
                        .addComponent(SiguientePregunta)))
                .addContainerGap(3, Short.MAX_VALUE))
        );
        examenLayout.setVerticalGroup(
            examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(examenLayout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(Exam)
                .addGap(31, 31, 31)
                .addGroup(examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Asignatura)
                    .addComponent(asig, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(Enunciado)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(examenLayout.createSequentialGroup()
                        .addComponent(R_1)
                        .addGap(62, 62, 62)
                        .addComponent(R_2))
                    .addGroup(examenLayout.createSequentialGroup()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(11, 11, 11)
                .addGroup(examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(R_3)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(examenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(R_4)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(29, 29, 29)
                .addComponent(SiguientePregunta)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        examen.setBounds(0, 0, 700, 450);
        GUI_Alumno.add(examen, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(128, 128, 128)
                .addComponent(autenticacion, javax.swing.GroupLayout.PREFERRED_SIZE, 518, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(204, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(GUI_Profesor, javax.swing.GroupLayout.PREFERRED_SIZE, 800, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 50, Short.MAX_VALUE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(25, 25, 25)
                    .addComponent(GUI_Alumno, javax.swing.GroupLayout.PREFERRED_SIZE, 774, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(51, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(199, 199, 199)
                .addComponent(autenticacion, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(214, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addGap(0, 115, Short.MAX_VALUE)
                    .addComponent(GUI_Profesor, javax.swing.GroupLayout.PREFERRED_SIZE, 495, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addGap(0, 101, Short.MAX_VALUE)
                    .addComponent(GUI_Alumno, javax.swing.GroupLayout.PREFERRED_SIZE, 509, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void user_inActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_user_inActionPerformed

    }//GEN-LAST:event_user_inActionPerformed

    private void b_entrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_entrarActionPerformed
        
        String user = new String(user_in.getText());
        String pass = new String(in_pass.getPassword());
        String tipoUser;
        PaqCORBA.Usuario u;
        
        cli.entrarSesion("localhost", 4444, this);
        u = cli.autenticar(user,pass);
        
        tipoUser = u.tipo;
        //System.out.println("tipoUser: "+tipoUser);
        
        
        if (tipoUser.equals("NULL"))
        {
            JOptionPane.showMessageDialog(this,"User o pass incorrecto", "Aviso",
            JOptionPane.ERROR_MESSAGE);
        }
        else
        {
            autenticacion.setVisible(false);
            switch (tipoUser) {
                case "Profesor":
                    {
                        // inicializo las listas de asignaturas
                        String[] listaAsig;
                        listaAsig = cli.listarAsignaturas();
                        for( String a : listaAsig) 
                        {
                            asignatura_in.addItem(a);
                            ed_asignatura_in.addItem(a);
                            creaEx_asig_in.addItem(a);
                            b_asignatura.addItem(a);
                        }
                        String a = asignatura_in.getSelectedItem().toString();
                        String[] listaTemas;
                        listaTemas = cli.listarTemas(a);
                        if (listaTemas != null)
                        {
                            tema_in.removeAllItems();
                            b_tema.removeAllItems();
                            creaEx_tema_in.removeAllItems();
                            for ( String tema: listaTemas) {
                               // System.out.println("Tema -- "+tema);
                                tema_in.addItem(tema);
                                creaEx_tema_in.addItem(tema);
                                b_tema.addItem(tema);
                            }
                        }
                        else
                            System.out.println("Lista de temas vac?a!!!!!!!!!!!!!!!!!");
                         // Hago visible la interfaz del profesor
                        GUI_Profesor.setVisible(true);
                        break;
                    }
                case "Alumno":
                    {
                        String[] listaAsig;
                        //String aux;
                        int i=1;
                        autenticacion.setVisible(false);
                        GUI_Alumno.setVisible(true);
                        //examen.setVisible(false);
                        listaAsig = cli.listarAsignaturas();
                        System.out.println("Hola1");
                        if(listaAsig.length == 0)
                            System.out.println("Lista es");
                        if( listaAsig == null )
                            System.out.println("Lista asignaturas null");
                        for( String a : listaAsig) 
                        {
                            System.out.println("Hola2");  
                            ListaAsignaturas.setValueAt("hola", 0, 1);
                            ListaAsignaturas.setValueAt(a, 0, 0);
                          
                        }
                        break;
                    }
            }
        }
  
    }//GEN-LAST:event_b_entrarActionPerformed

    private void in_passActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_in_passActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_in_passActionPerformed

    private void b_crearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_crearActionPerformed
        
        //Genero la lista de respuestas
        PaqCORBA.RespuestaPosible R[] = new PaqCORBA.RespuestaPosible[4];
        R[0] = new PaqCORBA.RespuestaPosible(respuesta1_in.getText(), check1_in.isSelected());
        R[1] = new PaqCORBA.RespuestaPosible(respuesta2_in.getText(), check2_in.isSelected());
        R[2] = new PaqCORBA.RespuestaPosible(respuesta3_in.getText(), check3_in.isSelected());
        R[3] = new PaqCORBA.RespuestaPosible(respuesta4_in.getText(), check4_in.isSelected());
        
        // Llamo a la funci?n correspondiente para a?adir una pregunta.
        cli.sesionCORBA.addPregunta(enunciado_in.getText(), maxResp, R, 
                (String)tema_in.getSelectedItem(), (String)asignatura_in.getSelectedItem());
        
        JOptionPane.showMessageDialog(this,"Pregunta a?adida", "Aviso", JOptionPane.INFORMATION_MESSAGE);
        
        // Borramos los textfield para iniciar el crear pregunta
        enunciado_in.setText("");
        respuesta1_in.setText("");
        respuesta2_in.setText("");
        respuesta3_in.setText("");
        respuesta4_in.setText("");
        check1_in.setSelected(false);
        check2_in.setSelected(false);
        check3_in.setSelected(false);
        check4_in.setSelected(false);
        
        this.ed_tema_inActionPerformed(evt);
    }//GEN-LAST:event_b_crearActionPerformed

    private void asignatura_inActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_asignatura_inActionPerformed
        String a = asignatura_in.getSelectedItem().toString();
        String[] listaTemas;
        listaTemas = cli.listarTemas(a);

               if (listaTemas != null)
               {
                   tema_in.removeAllItems();
                   for ( String tema: listaTemas) {
                       //System.out.println("Tema -- "+tema);
                       tema_in.addItem(tema);
                   }
               }
    }//GEN-LAST:event_asignatura_inActionPerformed

    private void asignatura_inItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_asignatura_inItemStateChanged
        // tras seleccionar un item, cambiar la lista de temas.
        
    }//GEN-LAST:event_asignatura_inItemStateChanged

    private void check1_inActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_check1_inActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_check1_inActionPerformed

    private void empezar_examenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_empezar_examenActionPerformed
        // TODO add your handling code here:
        menu_alumno.setVisible(false);
        examen.setVisible(true);
        asig.setText((String) listaExamenes.getSelectedItem());
    }//GEN-LAST:event_empezar_examenActionPerformed

    private void asigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_asigActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_asigActionPerformed

    private void R_1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_R_1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_R_1ActionPerformed

    private void creaEx_asig_inActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_creaEx_asig_inActionPerformed
        String a = creaEx_asig_in.getSelectedItem().toString();
        String[] listaTemas;
        listaTemas = cli.listarTemas(a);

        if (listaTemas != null)
        {
            creaEx_tema_in.removeAllItems();
            for ( String tema: listaTemas) {
                creaEx_tema_in.addItem(tema);
            }
        } 
    }//GEN-LAST:event_creaEx_asig_inActionPerformed

    private void b_anyadir_temaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_anyadir_temaActionPerformed
 
       Temas.addElement(creaEx_tema_in.getSelectedItem());
       temas_anyadidos.setModel(Temas);
       creaEx_asig_in.setEnabled(false);
    }//GEN-LAST:event_b_anyadir_temaActionPerformed

    private void b_crearExActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_crearExActionPerformed
        String[] temasAnyadidos = new String[Temas.getSize()];
        Temas.copyInto(temasAnyadidos);
        try {
            String fIni = fechaIni_in.getDate().toString().substring(8, 10) + "-" + 
                    fechaIni_in.getDate().toString().substring(4, 7) + "-" + 
                    fechaIni_in.getDate().toString().toString().substring(25, 29);
            String fFin = fechaFin_in.getDate().toString().substring(8, 10) + "-" + 
                    fechaFin_in.getDate().toString().substring(4, 7) + "-" + 
                    fechaFin_in.getDate().toString().toString().substring(25, 29);
            
            //System.out.println("Fecha Ini: " + fIni);
            
            cli.ponerExamen(fIni, fFin, (Integer.getInteger(creaEx_numPreguntas_in.getText())).shortValue() , creaEx_asig_in.getSelectedItem().toString(), temasAnyadidos);
            JOptionPane.showMessageDialog(this,"Examen creado", "Aviso",
            JOptionPane.INFORMATION_MESSAGE);
            creaEx_asig_in.setEnabled(true);
        } catch (exDemasiadasPreguntas ex) {
            ex.printStackTrace();
        }
        
    }//GEN-LAST:event_b_crearExActionPerformed

    private void fechaIni_inPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_fechaIni_inPropertyChange
        
        // Comprobaci?n de fechas
        if ( hoy.after(fechaIni_in.getCalendar()) )  // si la fecha actual es m?s tarde que la fecha introducida... 
        {
            JOptionPane.showMessageDialog(this,"Fecha de inicio incorrecta", "error",
            JOptionPane.ERROR_MESSAGE);
            fechaIni_in.setCalendar(hoy);
        }
        
        
       
    }//GEN-LAST:event_fechaIni_inPropertyChange

    private void fechaFin_inPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_fechaFin_inPropertyChange
        if ( fechaIni_in.getCalendar().after(fechaFin_in.getCalendar()) )  // si la fecha actual es m?s tarde que la fecha introducida... 
        {
            JOptionPane.showMessageDialog(this,"Fecha de inicio incorrecta", "error",
            JOptionPane.ERROR_MESSAGE);
            fechaIni_in.setCalendar(hoy);
        }
    }//GEN-LAST:event_fechaFin_inPropertyChange

    private void ed_tema_inItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_ed_tema_inItemStateChanged

   }//GEN-LAST:event_ed_tema_inItemStateChanged

    private void ed_tema_inActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ed_tema_inActionPerformed
        if (ed_tema_in.getItemCount() > 0) {
            String[] listaPregs;
            listaPregs = cli.sesionCORBA.listarPreguntas(ed_tema_in.getSelectedItem().toString(),
                    ed_asignatura_in.getSelectedItem().toString());
            if (listaPregs.length >= 1) {
                ed_pregunta_in.removeAllItems();
                for (String str : listaPregs) {
                    ed_pregunta_in.addItem(str);
                }
            }
        } else {
        }
    }//GEN-LAST:event_ed_tema_inActionPerformed

    private void ed_pregunta_inActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ed_pregunta_inActionPerformed
        if (ed_pregunta_in.getItemCount() > 0) {
            String[] resps = cli.sesionCORBA.listarRespuestasDescripcion(
                    ed_tema_in.getSelectedItem().toString(),
                    ed_asignatura_in.getSelectedItem().toString(),
                    ed_pregunta_in.getSelectedItem().toString());
            boolean[] correctas = cli.sesionCORBA.listarRespuestasCorrecta(
                    ed_tema_in.getSelectedItem().toString(),
                    ed_asignatura_in.getSelectedItem().toString(),
                    ed_pregunta_in.getSelectedItem().toString());

            int tam_resps = resps.length;
            ed_enunciado_in.setText(ed_pregunta_in.getSelectedItem().toString());
            if (tam_resps > 0) {
                ed_respuesta1_in.setText(resps[0]);
                ed_check1_in.setSelected(correctas[0]);
            }
            if (tam_resps > 1) {
                ed_respuesta2_in.setText(resps[1]);
                ed_check2_in.setSelected(correctas[1]);
            }
            if (tam_resps > 2) {
                ed_respuesta3_in.setText(resps[2]);
                ed_check3_in.setSelected(correctas[2]);
            }
            if (tam_resps > 3) {
                ed_respuesta4_in.setText(resps[3]);
                ed_check4_in.setSelected(correctas[3]);
            }
        } else {
        }
    }//GEN-LAST:event_ed_pregunta_inActionPerformed

    private void b_editar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_editar1ActionPerformed
        String[] respuestas = new String[4];
        boolean[] oks = new boolean[4];

        respuestas[0] = ed_respuesta1_in.getText();
        respuestas[1] = ed_respuesta2_in.getText();
        respuestas[2] = ed_respuesta3_in.getText();
        respuestas[3] = ed_respuesta4_in.getText();
        oks[0] = ed_check1_in.isSelected();
        oks[1] = ed_check2_in.isSelected();
        oks[2] = ed_check3_in.isSelected();
        oks[3] = ed_check4_in.isSelected();
        try {
            cli.sesionCORBA.editPregunta(ed_asignatura_in.getSelectedItem().toString(),
                    ed_pregunta_in.getSelectedItem().toString(),
                    ed_enunciado_in.getText(), maxResp, respuestas,
                    oks, ed_tema_in.getSelectedItem().toString());
            this.ed_tema_inActionPerformed(evt);
        } catch (PaqCORBA.exPreguntaNoExiste ex) {
            System.out.println("ERROR FATAL");
        }
        
        JOptionPane.showMessageDialog(this,"Pregunta modificada", "Aviso", JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_b_editar1ActionPerformed

    private void ed_check1_inActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ed_check1_inActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ed_check1_inActionPerformed

    private void ed_asignatura_inActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ed_asignatura_inActionPerformed
        String a = ed_asignatura_in.getSelectedItem().toString();
        String[] listaTemas;
        listaTemas = cli.listarTemas(a);

               if (listaTemas != null)
               {
                   ed_tema_in.removeAllItems();
                   for ( String tema: listaTemas) {
                       //System.out.println("Tema -- "+tema);
                       ed_tema_in.addItem(tema);
                   }
               }
    }//GEN-LAST:event_ed_asignatura_inActionPerformed

    private void b_asignaturaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_asignaturaActionPerformed
        // TODO add your handling code here:

        String a = b_asignatura.getSelectedItem().toString();
        String[] listaTemas;
        listaTemas = cli.listarTemas(a);

        if (listaTemas != null) {
            b_tema.removeAllItems();
            for (String tema : listaTemas) {
                //System.out.println("Tema1 -- " + tema);
                b_tema.addItem(tema);
            }
        }
    }//GEN-LAST:event_b_asignaturaActionPerformed

    private void b_temaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_temaActionPerformed
        if (b_tema.getItemCount() > 0) {
            String[] listaPregs;
            listaPregs = cli.listarPreguntas(b_tema.getSelectedItem().toString(),
                    b_asignatura.getSelectedItem().toString());
            if (listaPregs.length >= 1) {
                for (String str : listaPregs) {
                    b_pregunta.addItem(str);
                }
            }
        }
    }//GEN-LAST:event_b_temaActionPerformed

    private void b_preguntaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_preguntaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_b_preguntaActionPerformed

    private void borrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_borrarActionPerformed
        int op = 0;

        op = JOptionPane.showConfirmDialog(null, "Borrar Pregunta: ?Realmente desea eliminar la pregunta?", "Atencion", op);
        /*
         * op = 0 --> Borrar Pregunta
         */
        if (op == 0) {
            try {
                cli.borrarPregunta(b_asignatura.getSelectedItem().toString(), b_tema.getSelectedItem().toString(), b_pregunta.getSelectedItem().toString());
                JOptionPane.showMessageDialog(this, "Pregunta borrada", "Aviso",
                        JOptionPane.INFORMATION_MESSAGE);
                // b_tema.removeAllItems();
                //b_pregunta.removeAllItems();
            } catch (exPreguntaNoExiste ex) {
                Logger.getLogger(p_principal.class.getName()).log(Level.SEVERE, null, ex);
            }


        }
        //Vuelvo a mostrar las preguntas sin eliminar
        b_pregunta.removeAllItems();
        String[] listaPregs;
        listaPregs = cli.listarPreguntas(b_tema.getSelectedItem().toString(),
                b_asignatura.getSelectedItem().toString());
        if (listaPregs.length >= 1) {
            for (String str : listaPregs) {
                b_pregunta.addItem(str);
            }
        }
    }//GEN-LAST:event_borrarActionPerformed

    private void creaEx_numPreguntas_inActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_creaEx_numPreguntas_inActionPerformed
        if ( Integer.getInteger(creaEx_numPreguntas_in.getText()) < 1 )
        {
            JOptionPane.showMessageDialog(this,"N?mero de preguntas incorrecto", "error",
            JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_creaEx_numPreguntas_inActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Asignatura;
    private javax.swing.JPanel Asignaturas;
    private javax.swing.JLabel Enunciado;
    private javax.swing.JLabel Exam;
    private javax.swing.JPanel Examenes;
    private javax.swing.JLayeredPane GUI_Alumno;
    private javax.swing.JLayeredPane GUI_Profesor;
    public static javax.swing.JTable ListaAsignaturas;
    private javax.swing.JCheckBox R_1;
    private javax.swing.JCheckBox R_2;
    private javax.swing.JCheckBox R_3;
    private javax.swing.JCheckBox R_4;
    private javax.swing.JButton SiguientePregunta;
    private javax.swing.JTextField asig;
    private javax.swing.JComboBox asignatura_in;
    private javax.swing.JLayeredPane autenticacion;
    private javax.swing.JButton b_anyadir_tema;
    private javax.swing.JComboBox b_asignatura;
    private javax.swing.JButton b_crear;
    private javax.swing.JButton b_crearEx;
    private javax.swing.JButton b_editar1;
    private javax.swing.JButton b_entrar;
    private javax.swing.JComboBox b_pregunta;
    private javax.swing.JComboBox b_tema;
    private javax.swing.JButton borrar;
    private javax.swing.JPanel borrar_preguntas;
    private javax.swing.JCheckBox check1_in;
    private javax.swing.JCheckBox check2_in;
    private javax.swing.JCheckBox check3_in;
    private javax.swing.JCheckBox check4_in;
    private javax.swing.JComboBox creaEx_asig_in;
    private javax.swing.JTextField creaEx_numPreguntas_in;
    private javax.swing.JComboBox creaEx_tema_in;
    private javax.swing.JPanel crear_preguntras;
    private javax.swing.JComboBox ed_asignatura_in;
    private javax.swing.JCheckBox ed_check1_in;
    private javax.swing.JCheckBox ed_check2_in;
    private javax.swing.JCheckBox ed_check3_in;
    private javax.swing.JCheckBox ed_check4_in;
    private javax.swing.JTextArea ed_enunciado_in;
    private javax.swing.JPanel ed_preg_correcta;
    private javax.swing.JComboBox ed_pregunta_in;
    private javax.swing.JTextField ed_respuesta1_in;
    private javax.swing.JTextField ed_respuesta2_in;
    private javax.swing.JTextField ed_respuesta3_in;
    private javax.swing.JTextField ed_respuesta4_in;
    private javax.swing.JComboBox ed_tema_in;
    private javax.swing.JButton empezar_examen;
    private javax.swing.JTextArea enunciado;
    private javax.swing.JTextArea enunciado_in;
    private javax.swing.JLabel et_1;
    private javax.swing.JLabel et_2;
    private javax.swing.JLabel et_3;
    private javax.swing.JLabel et_4;
    private javax.swing.JLabel et_ID;
    private javax.swing.JLabel et_correcta;
    private javax.swing.JLabel et_edAsignatura1;
    private javax.swing.JLabel et_edPregunta1;
    private javax.swing.JLabel et_edResp5;
    private javax.swing.JLabel et_edResp6;
    private javax.swing.JLabel et_edResp7;
    private javax.swing.JLabel et_edResp8;
    private javax.swing.JLabel et_edTema1;
    private javax.swing.JLabel et_enunciado;
    private javax.swing.JLabel et_pass;
    private javax.swing.JLabel et_respuestas;
    private javax.swing.JLabel et_tema;
    private javax.swing.JLabel et_titCrearExamen;
    private javax.swing.JLabel et_titEdicionPreguntas1;
    private javax.swing.JLabel et_titProfesor;
    private javax.swing.JLabel et_usuario;
    private javax.swing.JPanel examen;
    private com.toedter.calendar.JDateChooser fechaFin_in;
    private com.toedter.calendar.JDateChooser fechaIni_in;
    private javax.swing.JPanel gestionar_preguntas;
    private javax.swing.JPasswordField in_pass;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JPanel lanzar_examen;
    private javax.swing.JLabel lanzar_titulo;
    private javax.swing.JComboBox listaExamenes;
    private javax.swing.JTabbedPane menu_alumno;
    private javax.swing.JTabbedPane menu_profesor;
    private javax.swing.JTabbedPane p_gestionar;
    private javax.swing.JTextArea resp_1;
    private javax.swing.JTextArea resp_2;
    private javax.swing.JTextArea resp_3;
    private javax.swing.JTextArea resp_4;
    private javax.swing.ButtonGroup respuesta1;
    private javax.swing.JTextField respuesta1_in;
    private javax.swing.ButtonGroup respuesta2;
    private javax.swing.JTextField respuesta2_in;
    private javax.swing.ButtonGroup respuesta3;
    private javax.swing.JTextField respuesta3_in;
    private javax.swing.ButtonGroup respuesta4;
    private javax.swing.JTextField respuesta4_in;
    private javax.swing.JScrollPane scroll_enunciado;
    private javax.swing.JComboBox tema_in;
    private javax.swing.JList temas_anyadidos;
    private javax.swing.JLabel titulo;
    private javax.swing.JTextField user_in;
    // End of variables declaration//GEN-END:variables
}
